package com.attendance.config;

import com.alibaba.fastjson2.JSON;
import com.attendance.utils.ResponseInfo;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class OVLogoutSuccessHandler implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        // 数据格式化 json
        String json = JSON.toJSONString(ResponseInfo.success(null,"注销成功 ヾ(￣▽￣)Bye~Bye~"));
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().println(json);
    }
}
